/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
// winscr16.hpp - PegScreen class definition for running as a Win32 app
//                at 16-bpp or 65K colors.
//
// Author: Kenneth G. Maxwell
//
// Copyright (c) 1997-2000 Swell Software 
//              All Rights Reserved.
//
// Unauthorized redistribution of this source code, in whole or part,
// without the express written permission of Swell Software
// is strictly prohibited.
//
// Notes:
//
//    This version of PegScreen is used for the Win32 development
//    environment. This version implements a 640x480x16 color PegScreen
//    under Win32. This resolution was chosen in order to be compatible
//    with the DOS screen and demo application. Other resolutions and/or
//    color depths could be easily be created using this module as an
//    example.
//
//
// This class defines all of the methods which must be supported in 
// instantiated screen classes. Users may of course add additional members
// in custom derived classes, but only those members found here will be used
// by PEG.
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

#if !defined(_PEGWINSCREEN_)
#define _PEGWINSCREEN_

#include "pro16scrn.hpp"   // Include the template class



/*--------------------------------------------------------------------------*/
// In the WIN32 environment, you can configure PEG to maintain
// a fixed virtual screen size (the most common case), or to re-size the
// virtual screen to match the client area of the MS Windows window client
// area.
//
// Most embedded platforms have a fixed screen size, and true emulation
// is best served by turning off PEG_SIZE_TO_WIN_CLIENT.
//
// As described in the programming manual, the WIN32 environment can be 
// configured for any screen resolution. The settings below configure PEG
// for VGA emulation. These values can be changed to emulate any target screen
// size.
/*--------------------------------------------------------------------------*/


typedef struct 
{
    BITMAPINFOHEADER bmhead;
    DWORD bmiColors[3];
} BMHEAD;

class PegWindow;

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
class PegWinScreen : public Pro16Screen
{
    public:
        PegWinScreen(const PegRect &);
        virtual ~PegWinScreen();

        virtual PEGINT BeginDraw(PegThing *Caller, const PegRect &Invalid,
            PEGINT Surface);
        virtual void EndDraw(void);

        HWND GetHWnd(void) {return mHWnd;}
        virtual PEGUBYTE *GetPalette(PEGULONG *pPutSize);
        virtual void ResetPalette(void);

       #ifndef PEG_SIZE_TO_WIN_CLIENT
        void SetNewWindowsWinSize(PEGINT Width, PEGINT Height)
        {
            mWinRectXOffset = (Width - mHRes) / 2;
            mWinRectYOffset = (Height - mVRes) / 2;            
        }
       #else
        void SetNewWindowsWinSize(PEGINT Width, PEGINT Height);
       #endif

        virtual void SetPalette(PEGINT First, PEGINT Count, 
                                const PEGUBYTE *pPal);

       #if defined(PEG_MOUSE_SUPPORT)
        virtual void SetPointerType(PEGUINT Type);
       #endif

        void SetHWnd(HWND hWnd);
        void SetWindowTitle(char *pText);

        // a couple of extensions for the MS Windows environment:

        PEGINT mWinRectXOffset;
        PEGINT mWinRectYOffset;
        PEGINT mWinRectMouseXOffset;
        PEGINT mWinRectMouseYOffset;

    protected:

        virtual void MemoryToScreen(void);

        PEGCOLOR *mpVidMem;
        HWND mHWnd;
        HPALETTE mhPalette;
        HDC  mHdc;

    private:
        
       #if defined(PEG_MULT_SOFT_SURFACES)
        void BlendSurface(DrawSurface *pSurface, PegRect &Copy);
        void CopySurface(DrawSurface *pSurface, PegRect &Copy);
        PEGUBYTE *mpCompositeBuffer;
       #endif


       #if defined(DRAW_VIEWPORTS)
        void DrawViewports(PegWindow *pw);
       #endif

       #ifdef PEGWIN32
        PEGUBYTE *mpDisplayBuff;       // for un-rotated display under Win32
       #endif

};


#endif

